package ex2.LinkedBinaryTree;

import java.util.Iterator;

public class LinkedBinaryTreeTester {
    public static void main(String[] args) {
        LinkedBinaryTree linkedBinaryTree2 = new LinkedBinaryTree(16);
        LinkedBinaryTree linkedBinaryTree6 = new LinkedBinaryTree();
        LinkedBinaryTree linkedBinaryTree1 = new LinkedBinaryTree(23,linkedBinaryTree6,linkedBinaryTree2);

        LinkedBinaryTree linkedBinaryTree4 = new LinkedBinaryTree(20);
        LinkedBinaryTree linkedBinaryTree5 = new LinkedBinaryTree(3);
        LinkedBinaryTree linkedBinaryTree3 = new LinkedBinaryTree(1,linkedBinaryTree5,linkedBinaryTree4);

        LinkedBinaryTree linkedBinaryTree = new LinkedBinaryTree(10,linkedBinaryTree1,linkedBinaryTree3);

        Iterator preTree = linkedBinaryTree.iteratorPreOrder();
        Iterator postTree = linkedBinaryTree.iteratorPostOrder();

        System.out.println("输出树");
        System.out.println(linkedBinaryTree.toString());
        System.out.println("输出树根的右子树" + linkedBinaryTree.getRight());
        System.out.println("是否含有数字3: " + linkedBinaryTree.contains(3));
        System.out.println("前序遍历");
        while (preTree.hasNext())
        {
            System.out.print(preTree.next() + " ");
        }
        System.out.println();
        System.out.println("后序遍历");

        while (postTree.hasNext())
        {
            System.out.print(postTree.next() + " ");
        }
    }
}
